//
//  HeaderCollectionViewCell.m
//  ArtWalker
//
//  Created by Mac Jc on 15/8/4.
//  Copyright (c) 2015年 Mac Jc. All rights reserved.
//

#import "HeaderCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "AllHeader.h"
#import "UIImage+ImageBlur.h"
#import <SDImageCache.h>

@implementation HeaderCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if ( self) {
        _imageView = [[UIImageView alloc] init];
        
        _backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
        _backgroundImageView.layer.cornerRadius = 4;
        _backgroundImageView.layer.masksToBounds = YES;
        [_backgroundImageView setContentMode:(UIViewContentModeScaleAspectFill)];
        _backgroundImageView.backgroundColor = kRandomColor;
        
        
        [self.contentView addSubview:_backgroundImageView];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_backgroundImageView.width / 2 - 28, _backgroundImageView.height /2.0 - 7, 56, 14)];
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.text = @"推荐";
        [self.contentView addSubview:_nameLabel];
        
        
    }
    return  self;
}

- (void)setArea:(AreaModel *)area{
    _area = area;
    if(_area.backImg){
//        [_backgroundImageView sd_setImageWithURL:[NSURL URLWithString:_area.backImg]];
        [_imageView sd_setImageWithURL:[NSURL URLWithString:_area.backImg]];
        _backgroundImageView.image = [_imageView.image boxblurImageWithBlur:0.75];
    } else {
        UIImage *image = [UIImage imageNamed:@"NineSchoolHolder"];
        _backgroundImageView.image = [image boxblurImageWithBlur:0.6];
    }
      _nameLabel.text = _area.place;
}



@end
